@echo off
set RegSvr=%WINDIR%\SYSTEM32\regsvr32.exe
set FileNameToRegister=CDevRichTextBox.ocx

if NOT Exist %RegSvr% goto REGSVR_NOT_EXIST 
if NOT Exist %FileNameToRegister% goto FILETOREGISTER_NOT_EXIST
 
echo   Registering %FileNameToRegister%
echo   On Vista please make sure this file in run under an Administrator account

rem unregister first then register
start /w %RegSvr% /u /s "%FileNameToRegister%"
start /w %RegSvr%  /s "%FileNameToRegister%"

echo   Finished
pause
goto EXIT

:REGSVR_NOT_EXIST
set FileNotExist=%RegSvr%
Goto FILE_NOT_EXIST
 
:FILETOREGISTER_NOT_EXIST 
set FileNotExist=%FileNameToRegister%
goto FILE_NOT_EXIST

:FILE_NOT_EXIST
echo '%FileNotExist%' File does not exist.
pause
goto EXIT

:EXIT